﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using NewLife;
using NewLife.Data;
using XCode;
using XCode.Cache;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace Datav.Design.Datas.Pocos;

/// <summary>限制配制</summary>
[Serializable]
[DataObject]
[Description("限制配制")]
[BindIndex("IX_p_limit_TenantId", false, "TenantId")]
[BindTable("p_limit", Description = "限制配制", ConnName = "datavdesign", DbType = DatabaseType.None)]
public partial class LimitConfig : ILimitConfig, IEntity<ILimitConfig>
{
    #region 属性
    private Int64 _Id;
    /// <summary>编号</summary>
    [DisplayName("编号")]
    [Description("编号")]
    [DataObjectField(true, false, false, 0)]
    [BindColumn("Id", "编号", "", DataScale = "time")]
    public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

    private Int64 _UserId;
    /// <summary>用戶Id</summary>
    [DisplayName("用戶Id")]
    [Description("用戶Id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("UserId", "用戶Id", "")]
    public Int64 UserId { get => _UserId; set { if (OnPropertyChanging("UserId", value)) { _UserId = value; OnPropertyChanged("UserId"); } } }

    private String _UserName;
    /// <summary>用戶名称</summary>
    [DisplayName("用戶名称")]
    [Description("用戶名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("UserName", "用戶名称", "")]
    public String UserName { get => _UserName; set { if (OnPropertyChanging("UserName", value)) { _UserName = value; OnPropertyChanged("UserName"); } } }

    private String _MobilePhone;
    /// <summary>用戶名称</summary>
    [DisplayName("用戶名称")]
    [Description("用戶名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("MobilePhone", "用戶名称", "")]
    public String MobilePhone { get => _MobilePhone; set { if (OnPropertyChanging("MobilePhone", value)) { _MobilePhone = value; OnPropertyChanged("MobilePhone"); } } }

    private Int64 _TenantId;
    /// <summary>租户id</summary>
    [DisplayName("租户id")]
    [Description("租户id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("TenantId", "租户id", "")]
    public Int64 TenantId { get => _TenantId; set { if (OnPropertyChanging("TenantId", value)) { _TenantId = value; OnPropertyChanged("TenantId"); } } }

    private String _SchoolName;
    /// <summary>学校名称</summary>
    [DisplayName("学校名称")]
    [Description("学校名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("SchoolName", "学校名称", "")]
    public String SchoolName { get => _SchoolName; set { if (OnPropertyChanging("SchoolName", value)) { _SchoolName = value; OnPropertyChanged("SchoolName"); } } }

    private Int32 _LimitTeacherNumber;
    /// <summary>教师帐号数</summary>
    [DisplayName("教师帐号数")]
    [Description("教师帐号数")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("LimitTeacherNumber", "教师帐号数", "")]
    public Int32 LimitTeacherNumber { get => _LimitTeacherNumber; set { if (OnPropertyChanging("LimitTeacherNumber", value)) { _LimitTeacherNumber = value; OnPropertyChanged("LimitTeacherNumber"); } } }

    private Int32 _LimitCaseNumber;
    /// <summary>创建项目数</summary>
    [DisplayName("创建项目数")]
    [Description("创建项目数")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("LimitCaseNumber", "创建项目数", "")]
    public Int32 LimitCaseNumber { get => _LimitCaseNumber; set { if (OnPropertyChanging("LimitCaseNumber", value)) { _LimitCaseNumber = value; OnPropertyChanged("LimitCaseNumber"); } } }

    private Int32 _LimitAccountNumber;
    /// <summary>每项目训练帐号数</summary>
    [DisplayName("每项目训练帐号数")]
    [Description("每项目训练帐号数")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("LimitAccountNumber", "每项目训练帐号数", "")]
    public Int32 LimitAccountNumber { get => _LimitAccountNumber; set { if (OnPropertyChanging("LimitAccountNumber", value)) { _LimitAccountNumber = value; OnPropertyChanged("LimitAccountNumber"); } } }

    private Int32 _RemainingCaseNumber;
    /// <summary>剩余项目数</summary>
    [DisplayName("剩余项目数")]
    [Description("剩余项目数")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("RemainingCaseNumber", "剩余项目数", "")]
    public Int32 RemainingCaseNumber { get => _RemainingCaseNumber; set { if (OnPropertyChanging("RemainingCaseNumber", value)) { _RemainingCaseNumber = value; OnPropertyChanged("RemainingCaseNumber"); } } }

    private Int32 _RemainingNumber;
    /// <summary>剩余帐号数</summary>
    [DisplayName("剩余帐号数")]
    [Description("剩余帐号数")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("RemainingNumber", "剩余帐号数", "")]
    public Int32 RemainingNumber { get => _RemainingNumber; set { if (OnPropertyChanging("RemainingNumber", value)) { _RemainingNumber = value; OnPropertyChanged("RemainingNumber"); } } }

    private Int64 _CreateBy;
    /// <summary>创建人</summary>
    [DisplayName("创建人")]
    [Description("创建人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("CreateBy", "创建人", "")]
    public Int64 CreateBy { get => _CreateBy; set { if (OnPropertyChanging("CreateBy", value)) { _CreateBy = value; OnPropertyChanged("CreateBy"); } } }

    private String _CreateName;
    /// <summary>创建人名称</summary>
    [Category("扩展")]
    [DisplayName("创建人名称")]
    [Description("创建人名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("CreateName", "创建人名称", "")]
    public String CreateName { get => _CreateName; set { if (OnPropertyChanging("CreateName", value)) { _CreateName = value; OnPropertyChanged("CreateName"); } } }

    private Int64 _UpdateBy;
    /// <summary>修改人</summary>
    [DisplayName("修改人")]
    [Description("修改人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("UpdateBy", "修改人", "")]
    public Int64 UpdateBy { get => _UpdateBy; set { if (OnPropertyChanging("UpdateBy", value)) { _UpdateBy = value; OnPropertyChanged("UpdateBy"); } } }

    private Int32 _IsDelete;
    /// <summary>是否删除0未删除1删除</summary>
    [DisplayName("是否删除0未删除1删除")]
    [Description("是否删除0未删除1删除")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("IsDelete", "是否删除0未删除1删除", "")]
    public Int32 IsDelete { get => _IsDelete; set { if (OnPropertyChanging("IsDelete", value)) { _IsDelete = value; OnPropertyChanged("IsDelete"); } } }

    private DateTime _CreateTime;
    /// <summary>创建时间</summary>
    [Category("扩展")]
    [DisplayName("创建时间")]
    [Description("创建时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("CreateTime", "创建时间", "")]
    public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }

    private DateTime _UpdateTime;
    /// <summary>更新时间</summary>
    [Category("扩展")]
    [DisplayName("更新时间")]
    [Description("更新时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("UpdateTime", "更新时间", "")]
    public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
    #endregion

    #region 拷贝
    /// <summary>拷贝模型对象</summary>
    /// <param name="model">模型</param>
    public void Copy(ILimitConfig model)
    {
        Id = model.Id;
        UserId = model.UserId;
        UserName = model.UserName;
        MobilePhone = model.MobilePhone;
        TenantId = model.TenantId;
        SchoolName = model.SchoolName;
        LimitTeacherNumber = model.LimitTeacherNumber;
        LimitCaseNumber = model.LimitCaseNumber;
        LimitAccountNumber = model.LimitAccountNumber;
        RemainingCaseNumber = model.RemainingCaseNumber;
        RemainingNumber = model.RemainingNumber;
        CreateBy = model.CreateBy;
        CreateName = model.CreateName;
        UpdateBy = model.UpdateBy;
        IsDelete = model.IsDelete;
        CreateTime = model.CreateTime;
        UpdateTime = model.UpdateTime;
    }
    #endregion

    #region 获取/设置 字段值
    /// <summary>获取/设置 字段值</summary>
    /// <param name="name">字段名</param>
    /// <returns></returns>
    public override Object this[String name]
    {
        get => name switch
        {
            "Id" => _Id,
            "UserId" => _UserId,
            "UserName" => _UserName,
            "MobilePhone" => _MobilePhone,
            "TenantId" => _TenantId,
            "SchoolName" => _SchoolName,
            "LimitTeacherNumber" => _LimitTeacherNumber,
            "LimitCaseNumber" => _LimitCaseNumber,
            "LimitAccountNumber" => _LimitAccountNumber,
            "RemainingCaseNumber" => _RemainingCaseNumber,
            "RemainingNumber" => _RemainingNumber,
            "CreateBy" => _CreateBy,
            "CreateName" => _CreateName,
            "UpdateBy" => _UpdateBy,
            "IsDelete" => _IsDelete,
            "CreateTime" => _CreateTime,
            "UpdateTime" => _UpdateTime,
            _ => base[name]
        };
        set
        {
            switch (name)
            {
                case "Id": _Id = value.ToLong(); break;
                case "UserId": _UserId = value.ToLong(); break;
                case "UserName": _UserName = Convert.ToString(value); break;
                case "MobilePhone": _MobilePhone = Convert.ToString(value); break;
                case "TenantId": _TenantId = value.ToLong(); break;
                case "SchoolName": _SchoolName = Convert.ToString(value); break;
                case "LimitTeacherNumber": _LimitTeacherNumber = value.ToInt(); break;
                case "LimitCaseNumber": _LimitCaseNumber = value.ToInt(); break;
                case "LimitAccountNumber": _LimitAccountNumber = value.ToInt(); break;
                case "RemainingCaseNumber": _RemainingCaseNumber = value.ToInt(); break;
                case "RemainingNumber": _RemainingNumber = value.ToInt(); break;
                case "CreateBy": _CreateBy = value.ToLong(); break;
                case "CreateName": _CreateName = Convert.ToString(value); break;
                case "UpdateBy": _UpdateBy = value.ToLong(); break;
                case "IsDelete": _IsDelete = value.ToInt(); break;
                case "CreateTime": _CreateTime = value.ToDateTime(); break;
                case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
                default: base[name] = value; break;
            }
        }
    }
    #endregion

    #region 关联映射
    #endregion

    #region 扩展查询
    #endregion

    #region 数据清理
    /// <summary>清理指定时间段内的数据</summary>
    /// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
    /// <param name="end">结束时间</param>
    /// <returns>清理行数</returns>
    public static Int32 DeleteWith(DateTime start, DateTime end)
    {
        return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
    }
    #endregion

    #region 字段名
    /// <summary>取得限制配制字段信息的快捷方式</summary>
    public partial class _
    {
        /// <summary>编号</summary>
        public static readonly Field Id = FindByName("Id");

        /// <summary>用戶Id</summary>
        public static readonly Field UserId = FindByName("UserId");

        /// <summary>用戶名称</summary>
        public static readonly Field UserName = FindByName("UserName");

        /// <summary>用戶名称</summary>
        public static readonly Field MobilePhone = FindByName("MobilePhone");

        /// <summary>租户id</summary>
        public static readonly Field TenantId = FindByName("TenantId");

        /// <summary>学校名称</summary>
        public static readonly Field SchoolName = FindByName("SchoolName");

        /// <summary>教师帐号数</summary>
        public static readonly Field LimitTeacherNumber = FindByName("LimitTeacherNumber");

        /// <summary>创建项目数</summary>
        public static readonly Field LimitCaseNumber = FindByName("LimitCaseNumber");

        /// <summary>每项目训练帐号数</summary>
        public static readonly Field LimitAccountNumber = FindByName("LimitAccountNumber");

        /// <summary>剩余项目数</summary>
        public static readonly Field RemainingCaseNumber = FindByName("RemainingCaseNumber");

        /// <summary>剩余帐号数</summary>
        public static readonly Field RemainingNumber = FindByName("RemainingNumber");

        /// <summary>创建人</summary>
        public static readonly Field CreateBy = FindByName("CreateBy");

        /// <summary>创建人名称</summary>
        public static readonly Field CreateName = FindByName("CreateName");

        /// <summary>修改人</summary>
        public static readonly Field UpdateBy = FindByName("UpdateBy");

        /// <summary>是否删除0未删除1删除</summary>
        public static readonly Field IsDelete = FindByName("IsDelete");

        /// <summary>创建时间</summary>
        public static readonly Field CreateTime = FindByName("CreateTime");

        /// <summary>更新时间</summary>
        public static readonly Field UpdateTime = FindByName("UpdateTime");

        static Field FindByName(String name) => Meta.Table.FindByName(name);
    }

    /// <summary>取得限制配制字段名称的快捷方式</summary>
    public partial class __
    {
        /// <summary>编号</summary>
        public const String Id = "Id";

        /// <summary>用戶Id</summary>
        public const String UserId = "UserId";

        /// <summary>用戶名称</summary>
        public const String UserName = "UserName";

        /// <summary>用戶名称</summary>
        public const String MobilePhone = "MobilePhone";

        /// <summary>租户id</summary>
        public const String TenantId = "TenantId";

        /// <summary>学校名称</summary>
        public const String SchoolName = "SchoolName";

        /// <summary>教师帐号数</summary>
        public const String LimitTeacherNumber = "LimitTeacherNumber";

        /// <summary>创建项目数</summary>
        public const String LimitCaseNumber = "LimitCaseNumber";

        /// <summary>每项目训练帐号数</summary>
        public const String LimitAccountNumber = "LimitAccountNumber";

        /// <summary>剩余项目数</summary>
        public const String RemainingCaseNumber = "RemainingCaseNumber";

        /// <summary>剩余帐号数</summary>
        public const String RemainingNumber = "RemainingNumber";

        /// <summary>创建人</summary>
        public const String CreateBy = "CreateBy";

        /// <summary>创建人名称</summary>
        public const String CreateName = "CreateName";

        /// <summary>修改人</summary>
        public const String UpdateBy = "UpdateBy";

        /// <summary>是否删除0未删除1删除</summary>
        public const String IsDelete = "IsDelete";

        /// <summary>创建时间</summary>
        public const String CreateTime = "CreateTime";

        /// <summary>更新时间</summary>
        public const String UpdateTime = "UpdateTime";
    }
    #endregion
}
